home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20031118-20041115 / 000125_fdc@columbia.edu_Fri Feb 27 15:18:51 2004.msg < prev    next >
Internet Message Format  |  2020-01-01  |  3KB

  1. Path: newsmaster.cc.columbia.edu!not-for-mail
  2. From: Frank da Cruz <fdc@columbia.edu>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: Comparing a file function output with built in variables
  5. Date: 27 Feb 2004 20:16:25 GMT
  6. Organization: Columbia University
  7. Lines: 66
  8. Message-ID: <slrnc3v9cp.dor.fdc@sesame.cc.columbia.edu>
  9. References: <bb076936.0402271132.6b6e3c53@posting.google.com>
  10. Reply-To: fdc@columbia.edu
  11. NNTP-Posting-Host: sesame.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1077912985 9066 128.59.59.56 (27 Feb 2004 20:16:25 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 27 Feb 2004 20:16:25 GMT
  15. User-Agent: slrn/0.9.7.4 (SunOS)
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:14830
  17.  
  18. In article <bb076936.0402271132.6b6e3c53@posting.google.com>,
  19. Matthew Dobbins wrote:
  20. : I am writing a client/server kermit script to send a file from one
  21. : location to another, but I only want to send if the file has changed. 
  22. : To overcome this, I decided to compare the md5sum output of the two
  23. : files.  If they are different, I will send.
  24. : I have the md5sum of the server file (the new file) on the remote
  25. : machine in the built in variable \v(inmatch) (i sent it this using
  26. : input/output commands).  I would like to compare the \v(inmatch) to
  27. : \f_getblock(\m(channel),32).
  28. : To make that last statement clear, here is what I'm doing on the
  29. : remote machine to get the md5sum of the file to be updated:
  30. : run md5sum ad.sxi > sum  (get the md4sum of the ad file and put into
  31. : file sum)
  32. : file open channel sum (open file for reading in kermit)
  33. :
  34. That's overkill; you can do it all in one statement:
  35.  
  36.   .\%a := \fword(\fcommand(md5sum ad.sxi),1)
  37.  
  38. That is, assign to \%a the first word of the output of "md5sum ad.sxi".
  39. "help function command" and "help function word" for details.
  40.  
  41. : ?COMPARE? \v(inmatch) with \f_getblock(\m(channel),32)  (they are both
  42. : the same types - 32 long)
  43. : IF the compare is true, i want to hang up, otherwise send
  44. if equal "\%a" "\v(inmatch)" {
  45.     hangup
  46. } else {
  47.     send ad.sxi
  48. }
  49.  
  50. In general I think you'd rather transfer the file unnecessarily than
  51. skip transferring it when you should have.  Thus you might want to precheck
  52. the results for validity; e.g.:
  53.  
  54. if not defined \%a ...
  55. if not = \flen(\%a) 32 ...
  56.  
  57. : Can anyone help me with the compare?  I have searched the
  58. : documentation and cannot find anything that will do this.  Any
  59. : suggestions?
  60. "help if".  Note that the basic documentation is the manual, "Using
  61. C-Kermit".  The online stuff is all supplemental.
  62.  
  63. Btw, a better way to get the remote md5sum would be to do it through the
  64. server:
  65.  
  66.   query kermit command(md5sum filename)
  67.   if fail ...
  68.  
  69. and then:
  70.  
  71.   if equal \%a \fword(\v(query),1) ...
  72.  
  73. Not only is this simpler, but the result is transferred to the
  74. script with an error detecting and correcting protocol, which can make
  75. a difference on noisy connections.
  76.  
  77. - Frank
  78.